#include <wiringPi.h>
#include <iostream> 

using namespace std; 

#define INPUT_PIN 7
#define OUTPUT_PIN 16 

int main()
{
	wiringPiSetup();
	pinMode(INPUT_PIN, INPUT); 
	pinMode(OUTPUT_PIN, OUTPUT); 
/*	
	for(int i=0; i<26; i++)
	{
		if(i != 7)
			pinMode(i, OUTPUT);
	}

	for(int i=0; i<26; i++)
	{
		if(i != 7)
			digitalWrite(i, 0); 
	}
		
	int wait; 
	for(int i=0; i<26; i++)
	{
		cout << "Pin: " << i << endl; 
		if(i != 7)
			digitalWrite(i, 1);
 
		cin >> wait; 
	}
*/
	bool meUpright = true; 
	bool himUpright = true; 

	while(1)
	{

		// Checks other guy status
		
		// Check my status
		if(digitalRead(INPUT_PIN) > 0){
			meUpright = true; 
		}
		else{
			meUpright = false; 
		}
		
		if(meUpright && himUpright)
		{
			// Set LED on
			cout << "ON" << endl; 
			digitalWrite(OUTPUT_PIN, 1);
		}else{
			cout << "NOT ON" << endl; 
			// Set LED off
			digitalWrite(OUTPUT_PIN, 0); 
		}
		delay(100); 
		digitalWrite(OUTPUT_PIN, 0); 
		delay(100); 
	}

	return 0; 
}
	
